<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <style type="text/css">
        .f14 {
            font-size: 14px!important;
        }
    </style>
</head>
<body>
<%@include file="../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <div class="section-main">
            <div class="layui-tab layui-tab-brief mt20" lay-filter="type">
                <ul class="layui-tab-title">
                    <li class="layui-this">众筹<span  class="pl5">${page.totalCount}</span>人</li>
                    <li>联合发起<span class="pl5">${representNum}</span>人</li>
                </ul>
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/activityMultiple/project/listForEvent.do?eventId=${crowdfundEvent.id}" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item">
                                        <label class="search-form-lable">活动状态</label>
                                        <div class="check-btn-inner">
                                            <c:set var="numArray" value="${fn:split('一,二,三,四,五', ',')}"></c:set>
                                            <c:forEach var="gradation" items="${eventGradations}">
                                                <c:if test="${ongoingGradation.gradation == gradation.gradation}">
                                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'${gradation.id}','#myForm')"
                                                       ${currentGradation == gradation.id ? 'class="active"' : ''} >当前</a>
                                                </c:if>
                                                <c:if test="${ongoingGradation.gradation != gradation.gradation}">
                                                    <a href="javascript:void(0);" onclick="setTimeType($(this),'${gradation.id}','#myForm')"
                                                        ${currentGradation == gradation.id ? 'class="active"' : ''}>第${numArray[gradation.gradation - 1]}场</a>
                                                </c:if>
                                            </c:forEach>
                                            <input type="hidden" name="currentGradation" value="${currentGradation}"/>
                                        </div>
                                    </li>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item-inline">
                                        <label class="search-form-lable" style="text-indent: 13px;">众筹者</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorName" autocomplete="off" class="layui-input"
                                                   value="${projectWithAuthor.authorName}" placeholder="众筹者" />
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <label class="search-form-lable">联系电话</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorMobile" autocomplete="off" placeholder="联系电话"
                                                   class="layui-input" value="${projectWithAuthor.authorMobile}" />
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <label class="search-form-lable">排序方式</label>
                                        <div class="layui-input-inline">
                                            <select name="sort">
                                                <option value="0" ${projectWithAuthor.sort == 0 ? 'selected="selected"' : ''}>金额最多</option>
                                                <option value="1" ${projectWithAuthor.sort == 1 ? 'selected="selected"' : ''}>时间最近</option>
                                            </select>
                                        </div>
                                    </li>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item-inline">
                                        <label class="search-form-lable">筛选金额</label>
                                        <div class="layui-input-inline">
                                            <input type="number" name="amountGOE" autocomplete="off" class="layui-input" min="0.01"
                                                   value="${projectWithAuthor.amountGOE}" placeholder="最小金额" />
                                        </div>
                                        -
                                        <div class="layui-input-inline">
                                            <input type="number" name="amountLOE" autocomplete="off" class="layui-input" min="0.01"
                                                   value="${projectWithAuthor.amountLOE}" placeholder="最大金额" />
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger" href="javascript:submitFunction('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal" href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <div class="my-act-list-content">
                        <ul class="num">
                            <div class="l">
                                <li class="f16">总金额
                                    <span class="red">
                                        <fmt:formatNumber pattern="#,###.##" value="${totalMoney}"/>
                                    </span> 元
                                </li>
                                <li class="f16">退款金额
                                    <span class="red">
                                        <fmt:formatNumber pattern="#,###.##" value="${refundMoney}"/>
                                    </span> 元
                                </li>
                                <li class="f16">消费金额
                                    <span class="red">
                                        <fmt:formatNumber pattern="#,###.##" value="${consumedAmount}"/>
                                    </span> 元
                                </li>
                                <li class="f16">剩余金额
                                    <span class="red">
                                        <fmt:formatNumber pattern="#,###.##" value="${remainMoney}"/>
                                    </span> 元
                                </li>
                            </div>
                            <div class="r">
                                <li style="cursor: pointer;" class="r">
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank" href="javascript:txz.expireCheck('', function() { sendMessage() })">发送短信</a>
                                    <a class="layui-btn layui-btn-danger layui-btn-sm" href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a>
                                </li>
                            </div>
                            <p class="cl"></p>
                        </ul>
                        <div class="cl">
                            <table class="layui-table layui-form">
                                <colgroup>
                                    <col width="50px">
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th><input type="checkbox" id="chkAll" lay-skin="primary" lay-filter="chkAll"/></th>
                                    <th>序号</th>
                                    <th>众筹者</th>
                                    <th>渠道</th>
                                    <th>报名来源</th>
                                    <th>下级报名人数</th>
                                    <th>公司</th>
                                    <th>区域</th>
                                    <th>职务</th>
                                    <th>联系电话</th>
                                    <th>支持人数</th>
                                    <th>支持金额</th>
                                    <th>真实金额</th>
                                    <th>活动金额</th>
                                    <th title="已参赛的活动金额">消费金额<i class="iconfont icon-ask f14"></i></th>
                                    <c:if test="${ongoingGradation.id == currentGradation}">
                                        <th title="支持金额-已参赛的活动金额">剩余金额<i class="iconfont icon-ask f14"></i></th>
                                    </c:if>
                                    <c:if test="${ongoingGradation.id != currentGradation}">
                                        <th>参与状态</th>
                                    </c:if>
                                    <th>浏览量</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="projectEntity" items="${outputList}" varStatus="st">
                                    <tr class="detail-content">
                                        <td><input type="checkbox" value="${projectEntity.id}" name="chk"
                                                   lay-skin="primary" data-memberid="${projectEntity.authorId}" class="goods-chk" /></td>
                                        <td>${page.limit * (page.page-1) + st.count}</td>
                                        <td class="table-member"
                                            onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${projectEntity.authorId}','400px','470px')">
                                            <div class="member-cell">
                                                <div class="member-logo common-img">
                                                    <img src="<c:if test="${ projectEntity.authorLogo!= null}">${projectEntity.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                         alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1">
                                                    <a class="blue" title="${projectEntity.authorName}" href="javascript:void(0);">${projectEntity.authorName}</a>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="ellipsis-1" title="${projectEntity.publisher}">${projectEntity.publisher}</div>
                                        </td>
                                        <c:if test="${ not empty projectEntity.parentId}">
                                            <td class="table-member"
                                                onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${projectEntity.parentId}','400px','470px')">
                                                <div class="member-cell">
                                                    <div class="member-logo common-img">
                                                        <img src="<c:if test="${projectEntity.parentLogo != null}">${projectEntity.parentLogo}?imageMogr2/auto-orient/crop/126x126</c:if>"
                                                             alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)" />
                                                    </div>
                                                    <div class="member-name ellipsis-1">
                                                        <a class="blue" title="${projectEntity.parentName}" href="javascript:void(0);">${projectEntity.parentName}</a>
                                                    </div>
                                                </div>
                                            </td>
                                        </c:if>
                                        <c:if test="${empty projectEntity.parentId}">
                                            <td></td>
                                        </c:if>
                                        <td>
                                            <a href="javascript:void(0);" class="blue ${projectEntity.childNum > 0 ? 'childNum' : ''} count-num" data-id="${projectEntity.id}">${projectEntity.childNum}</a>
                                        </td>
                                        <td class="ellipsis-1">${projectEntity.authorCompany}</td>
                                        <td>${projectEntity.cityName}</td>
                                        <td>${projectEntity.authorJobTitle}</td>
                                        <td>${projectEntity.authorMobile}</td>
                                        <td>
                                            <a href="javascript:void(0);" data-id="${projectEntity.id}"
                                               class="blue ${projectEntity.actualAmount > 0||projectEntity.isSuccess == 4  ? 'favorerNum' : ''} count-num"
                                               data-name="${projectEntity.authorName}">${projectEntity.favorerNum}</a>
                                        </td>
                                        <td>
                                            <a href="javascript:void(0);" data-id="${projectEntity.id}"
                                               class="blue ${projectEntity.actualAmount > 0 ||projectEntity.isSuccess == 4 ? 'actualAmount' : ''} count-num"
                                               data-name="${projectEntity.authorName}"> ${projectEntity.actualAmount}</a>
                                        </td>
                                        <td>
                                            <c:if test="${empty projectEntity.realTimeAmount || null == projectEntity.realTimeAmount}">0.0</c:if>
                                            <c:if test="${ not empty projectEntity.realTimeAmount || null != projectEntity.realTimeAmount}">
                                                ${projectEntity.realTimeAmount}
                                            </c:if>
                                        </td>
                                        <td>
                                            <fmt:formatNumber value="${projectEntity.gradationTargetAmount}" pattern="#.##"/>
                                        </td>
                                        <td>
                                            <a href="javascript:openDialogShow('查看“${projectEntity.authorName}”的数据','${ctx}/activityMultiple/project/projectGradationList.do?projectId=${projectEntity.id}','550px','470px')">
                                                <fmt:formatNumber value="${projectEntity.consumedAmount}" pattern="#.##"/>
                                            </a>
                                        </td>
                                        <td>
                                            <c:if test="${ongoingGradation.id == currentGradation}">
                                                <a href="javascript:openDialogShow('查看“${projectEntity.authorName}”的数据','${ctx}/activityMultiple/project/projectGradationList.do?projectId=${projectEntity.id}','550px','470px')">
                                                    <fmt:formatNumber value="${projectEntity.remindAmount}" pattern="#.##"/>
                                                </a>
                                            </c:if>
                                            <c:if test="${ongoingGradation.id != currentGradation}">
                                                ${projectEntity.competitionStatus == 1 ? '参与' : ''}${projectEntity.competitionStatus == 0 ? '未参与' : ''}
                                            </c:if>
                                        </td>
                                        <td>${projectEntity.viewNum}</td>
                                        <td class="tb-opts">
                                            <div class="comm-opts">
                                                <a href="javascript:openDialogShow('查看“${projectEntity.authorName}”的数据','${ctx}/crowdfund/support/chartView.do?projectId=${projectEntity.id}&eventId=${crowdfundEvent.id}','1050px','500px')">数据查看</a>
                                            </div>
                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div>
        <%@include file="../include/footer.jsp" %>
    </section>
    <%-- 参赛状态标记 --%>
    <div id="setCompetitionDiv" class="layui-form dn">
        <div style="width: 300px; margin: 40px auto 0px; text-align: center;">
            <div class="mb20">
                <input type="radio" title="参与" name="competitionStatus" value="1" />
                <input type="radio" title="不参与" name="competitionStatus" value="0" />
            </div>
            <div>
                注：标记为不参与后，资金自动转移到下一场，标记后不可更改，标记为参与后方可提现。
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>

<script type="text/javascript">
    var laytpl, layForm;
    txz.initHeader({
        nav: [{
            name: '众筹主题',
            href: '${ctx}/crowdfundMultiple/event/list.do'
        }, {
            name: '${crowdfundEvent.name}'
        }, {
            name: '数据查看',
            curr: true
        }],
        btns: [{
            type: 'back'
        }]
    });
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['element', 'laytpl', 'form'], function () {
            var element = layui.element;
            laytpl = layui.laytpl, layForm = layui.form;

            element.on('tab(type)', function (data) {
                if (data.index == 0) {
                    window.location.href = "${ctx}/activityMultiple/project/listForEvent.do?eventId=${crowdfundEvent.id}";
                } else if (data.index == 1) {
                    window.location.href = "${ctx}/activityMultiple/represent/listForEvent.do?eventId=${crowdfundEvent.id}";
                }
            });

            layForm.on('checkbox(chkAll)', function (data) {
                var checked = data.elem.checked;
                if (checked) {
                    $(".goods-chk").each(function (index, ele) {
                        var disabled = $(ele).attr('disabled');
                        if (!disabled) {
                            $(ele).prop("checked", true);
                        }
                    });
                } else {
                    $(".goods-chk").each(function (index, ele) {
                        $(ele).prop("checked", false);
                    });
                }
                layForm.render('checkbox');
            });
        });

        $('.favorerNum').click(function () {
            var projectId = this.dataset.id;
            window.location.href = '${ctx}/activityMultiple/support/event/listForProject.do?eventId=${crowdfundEvent.id}&projectId=' + projectId + '&source=1';
        });

        $('.actualAmount').click(function () {
            var projectId = this.dataset.id;
            window.location.href = '${ctx}/activityMultiple/support/event/listForProject.do?eventId=${crowdfundEvent.id}&projectId=' + projectId + '&source=1';
        });

        $('.childNum').click(function () {
            var id = this.dataset.id;
            openDialogShow('下级报名人数', '${ctx}/crowdfund/project/childList.do?id=' + id, '800px', '500px')
        });
    })

    function sendMessage() {
        var array = new Array();
        $(".goods-chk:checked").each(function (index, ele) {
            array.push($(ele).val());
        })
        if (array.length == 0) {
            util.layerMsgError('请选择需要推送短信的众筹者');
            return false;
        }
        var url = '${ctx}/activityMultiple/zcActivity/toSendMessage.do?eventId=${crowdfundEvent.id}&projectIds='+array.join(',');
        openDialog('发送短信', url, '700px', '500px')
    }

    function openDialog(title, url, width, height, cb, target) {
        var index = layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }
            },
            cancel: function (index) {
            }
        });
    }

    /**
     * 数据导出
     */
    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/activityMultiple/project/listForEventExport.do?eventId=${crowdfundEvent.id}", $("#myForm").serialize(), function (res) {
                layer.close(loadIndex);
                if (res.success) {
                    window.location.href = res.data;
                } else {
                    util.layerMsgError(res.description)
                }
            });
            top.layer.close(index);
        });
    }
</script>
</body>
</html>
